import { UserState } from '@/store/modules/user/types'
import axios from 'axios'
import type { RouteRecordNormalized } from 'vue-router'
import { encrypt } from '@/utils/cyrptoUtil'

export interface LoginData {
  username: string
  password: string
  password_encrypt : string
}

export function login(data: LoginData) {
  data.password_encrypt = encrypt(data.password)
  return axios.post('/user/login', data)
}

export function signInWx(data:Object) {
  return axios.post('/user/wxlogin', data)
}

export function logout() {
  return axios.post('/user/logout')
}

export function getUserInfo() {
  return axios.post<UserState>('/user/info', {'test' : 'test'})
}

export function getMenuList() {
  return axios.post<RouteRecordNormalized[]>('/api/user/menu')
}
